package com.liao.furns.web; /**
 * @author lzp
 * @version 1.0
 * lzpnb!
 */

import com.liao.furns.pojo.Admin;
import com.liao.furns.pojo.Furn;
import com.liao.furns.pojo.Member;
import com.liao.furns.service.AdminService;
import com.liao.furns.service.impl.AdminServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.List;

public class AdminServlet extends BasicServlet {
    private   AdminService adminService = new AdminServiceImpl();
    public void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        Admin admin = new Admin(null, username, password, null);
        Member member = new Member(null, username, password, null);
        if(adminService.login(admin) != null){
            request.getSession().setAttribute("member",member);
            request.getRequestDispatcher("/views/manage/manage_menu.jsp").forward(request,response);
        }else {
            request.setAttribute("username",admin.getUsername());
            request.setAttribute("nameorpwderror","用户名或密码错误");
            request.getRequestDispatcher("/views/manage/manage_login.jsp").forward(request,response);
        }
    }
}
